<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Appliance_model extends CI_Model {

    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
    
    function add_appliance($_POST){
		$this->db->query("INSERT INTO appliance_info VALUES (
			'".$_POST["student_number"]."',
			'".$_POST["first_name"]."',
			'".$_POST["middle_name"]."',
			'".$_POST["last_name"]."',
			'".$_POST["type_of_appliance"]."',
			'".$_POST["date_installed"]."',
			'".$_POST["date_cancelled"]."',
			'".$_POST["remark"]."'
			)");
	}
	
	function check_appliance($_POST){
		return $this->db->query("
			SELECT * FROM appliance_info 
			WHERE student_number='".$_POST["student_number"]."'");
	}
	
	function edit_appliance($_POST){
		$this->db->query("UPDATE appliance_info SET
			first_name='".$_POST["first_name"]."',
			middle_name='".$_POST["middle_name"]."',
			last_name='".$_POST["last_name"]."',
			type_of_appliance='".$_POST["type_of_appliance"]."',
			date_installed='".$_POST["date_installed"]."',
			date_cancelled='".$_POST["date_cancelled"]."'			
			WHERE student_number='".$_POST["student_number"]."'
			");

	}

	function get_all_appliances($_POST){
		return $this->db->query("SELECT * FROM appliance_info");
	}
	
	function delete_appliance($_POST){
		$this->db->query("DELETE FROM appliance_info WHERE student_number='".$_POST['delete']."'");
		
	}
	
	function delete_all_appliances($_POST){
		$this->db->query("DELETE FROM appliance_info");
	}
	
}
/* End of file appliance_model.php */
/* Location: ./application/models/appliance_model.php */
?>